/**********************************************
 * 	TestAdverb.java							  *
 *  Course: CS3343							  *
 *  Version: 2.5    Release 3				  *
 *  Last Modified : 22 MAR 2013			      *
 **********************************************/
package testChecker;

import org.junit.Before;
import junit.framework.TestCase;
import checker.Adverb;
import org.junit.Test;

public class TestAdverb extends TestCase {


	@Before
	public void setUp() throws Exception {

	}

	//unit test for the Adverb class
	@Test
	public void testAdverbA(){
		
		class AdverbStub extends Adverb{
			public  boolean isOfType(String word){
				//get all the words starting with the letter that is the same as the initial letter of the input word
				//the second argument is the type of words to be retrieved for comparison, in this case, nouns
				//the return value is an array containing all the relevant words
				String[] adverbs = {"optionally", "obviously","occasionally", "objectively" };
				
				//simply compare each value in the array with the input word
				for(int i = 0; i < adverbs.length; i++){
					if(adverbs[i].equalsIgnoreCase(word))
						//returning true means this is a noun
						return true;
				}
				return false;
			}
		
		};
		
		AdverbStub adverbStub = new AdverbStub();
		
		boolean result = adverbStub.isOfType("optionally");
		assertEquals(true, result);
		
	}

	//unit test for the Adverb class
	@Test
	public void testAdverbB(){
		
		class AdverbStub extends Adverb{
			public  boolean isOfType(String word){
				//get all the words starting with the letter that is the same as the initial letter of the input word
				//the second argument is the type of words to be retrieved for comparison, in this case, nouns
				//the return value is an array containing all the relevant words
				String[] adverbs = {"ReAsOnAbLy", "racially","randomly", "repeatedly" };
				
				//simply compare each value in the array with the input word
				for(int i = 0; i < adverbs.length; i++){
					if(adverbs[i].equalsIgnoreCase(word))
						//returning true means this is a noun
						return true;
				}
				return false;
			}
		
		};
		
		AdverbStub adverbStub = new AdverbStub();
		
		boolean result = adverbStub.isOfType("ReAsOnAbLe");
		assertEquals(false, result);
		
	}

	//integration test 1 with the FileIO class
	@Test
	public void testIntegrationWithFileIO1(){
		 Adverb adverb = new Adverb();
		boolean result = adverb.isOfType("silently");
		assertEquals(true, result);
		
	}
	
	//integration test 2 with the FileIO class
	@Test
	public void testIntegrationWithFileIO2(){
		Adverb adverb = new Adverb();
		boolean result = adverb.isOfType("hell");
		assertEquals(false, result);
		
	}
	
	//integration test 3 with the FileIO class
	@Test
	public void testIntegrationWithFileIO3(){
		 Adverb adverb = new Adverb();
		boolean result = adverb.isOfType("apparently");
		assertEquals(true, result);
		
	}
	
	//integration test 4 with the FileIO class
	@Test
	public void testIntegrationWithFileIO4(){
		Adverb adverb = new Adverb();
		boolean result = adverb.isOfType("hip");
		assertEquals(false, result);
		
	}
	
	//integration test 5 with the FileIO class
	@Test
	public void testIntegrationWithFileIO5(){
		 Adverb adverb = new Adverb();
		boolean result = adverb.isOfType("internationally");
		assertEquals(true, result);
		
	}
	
	//integration test 6 with the FileIO class
	@Test
	public void testIntegrationWithFileIO6(){
		Adverb adverb = new Adverb();
		boolean result = adverb.isOfType("fly");
		assertEquals(false, result);
		
	}
	
	// test user-defined constructor
	@Test
	public void testUserDefinedConstructor() {
		Adverb adverb = new Adverb("[adv]");
		String result = adverb.getSign();
		assertEquals("[adv]", result);

	}

}
